var e = getApp(), t = void 0;

Page({
    data: {
        api: e.com.API
    },
    onLoad: function(e) {
        t = this;
        var o = JSON.parse(e.data);
        t.setData({
            userInfo: o
        }), "" != o.qr_code && null != o.qr_code || this.getQrcode();
    },
    getQrcode: function() {
        e.com.post("wx/retail/qrcode", {}, function(e) {
            0 === e.errno && t.setData({
                "userInfo.qr_code": e.data.qr_code
            });
        });
    },
    downloadCode: function() {
        wx.downloadFile({
            url: this.data.api + this.data.userInfo.qr_code,
            success: function(e) {
                wx.saveImageToPhotosAlbum({
                    filePath: e.tempFilePath,
                    success: function(e) {
                        wx.showToast({
                            title: "保存成功"
                        });
                    }
                });
            },
            fail: function() {
                console.log(res);
            }
        });
    },
    onShareAppMessage: function() {
        var e = wx.getStorageSync("wxapp");
        return {
            title: e.shareTitle,
            path: e.sharePath + "?wx_id=" + wx.getStorageSync("wx_id")
        };
    }
});